<html>
<head>
<script type="text/javascript" src="jquery-1.4.1.js"></script>
<style>
body
{

font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
color: #036;

}
</style>

<script>
function fillDropDownLists(htmlobj) {
   var xmlhttp;

   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp = new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.onreadystatechange = function()
   {
       if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
       {
           //TODO: validate 5000 and 6000 tables
           var ddl_options = "<option value=''></option>";
           var courses_string = xmlhttp.responseText;
           
           courses_string = courses_string.substring(0, courses_string.length - 1);
           var course_codes = courses_string.split(",");

           for (var i = 0; i < course_codes.length; i++) {
               ddl_options += "<option value='" + course_codes[i] + "'>" + course_codes[i] + "</option>";
           }

           htmlobj.innerHTML = ddl_options;
           //document.getElementsByName("classNumber5_ti")[0].innerhtml = ddl_options;

       }
   }
   xmlhttp.open("GET", "getuser1.php", true);
   xmlhttp.send();
}


function fillRow(htmlobj)
{
//alert(htmlobj)
var e = htmlobj;


var objId = htmlobj.getAttribute('id');
var stringLength = objId.length; // this will be 16
var lastChar = objId.charAt(stringLength - 1);
//alert(lastChar);
var strUser = e.options[e.selectedIndex].value;

   if (strUser=="") {
   return;} 
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    var responseArray = xmlhttp.responseText.split(" $$ ");
    
    
    //document.getElementById("courseName6k3").innerHTML=responseArray[0];
    document.getElementById("courseName"+lastChar).value =responseArray[0];
     document.getElementById("courseSemester"+lastChar).value =responseArray[1];
     document.getElementById("courseYear"+lastChar).value =responseArray[2];
    document.getElementById("courseGrade"+lastChar).value =responseArray[3];
     document.getElementById("courseArea"+lastChar).value =responseArray[4];


	
//     document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.open("GET","getCourseContent.php?q="+strUser,true);
  xmlhttp.send();
}



</script>

</head>

<body>


<!-- header.css  -->
<div id = "headerwrapper">

	<table id = "headerTable">
		<tr>
			<td>
				<img id = "unoLogo" src="Logo1.jpg" /> 
			</td>
			<td>
		<font size ="16"> Department of Computer Science </font>
				
			</td>
			<td>
			</td>

			
		</tr>
	</table>

	
<div id = "bodywrapper">


	<center><b>Graduate Checklist - Non-Thesis option</b></center>

<!--courseSelectionForm.css -->



<form action = "nonThesis.php" method ="post" id = "courseSelectionNonThesForm">

	<div id = "nameDiv">
		<label>First Name:</label>
		<input type ="text" size = "20" name ="firstname" />
		<label>Last Name:</label>
		<input type ="text" size = "20" name ="lastname" />	
		<label>Student Id:</label>
		<input type ="text" size = "20" name ="studentId" />	
	</div>	




<!-- 4000 level course table -->
<div class = "courseTableWrapper">

<div class ="courseTableCaption"> 5000 level </div>
<div class ="courseTableCaptionNote"> At most 4 5000 level courses count towards the degree requirements.</div>

	<table id = "courseSelectionTable4000">

		<th>Number</th>
		<th>Title</th>
		<th>Semester</th>
		<th>Year</th>
		<th>Grade</th>
		<th>Area</th>
		
		<?php
$con = mysqli_connect('localhost','root','','db4208');
if (!$con) {
  die('Could not connect: ' . mysqli_error($con));
}
session_start();
$useremail=$_SESSION['email'];
$i = 1;
$alpha = array(
1=>"A",
2=>"B",
3=>"C",
4=>"D",
);
$sql="SELECT u.*, d.* FROM `users` u join data d on u.user_id = d.Studentid WHERE user_email='$useremail'";
$result = mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($result)) {
?>

<tr id="<?=$alpha[$i];?>">
		<td>
<select id="classNumber<?=$alpha[$i];?>" name="aform1" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
 <option selected="selected"><?= $row['c_number']?></option>
 
</select> 
</td>

<td class = "courseTitle"><input type ="text" name ="courseName<?=$i;?>" size = "40" id ="courseName<?=$alpha[$i];?>" value="<?= $row['c_title']?>"/></td>
<td class = "courseSemester"><input type="text" size="8" name="courseSemester<?=$i;?>" id= "courseSemester<?=$alpha[$i];?>" value="<?= $row['c_sem']?>"></td>
<td class = "courseYear"><input type="text" size="8" name="couseYear<?=$i;?>" id= "courseYear<?=$alpha[$i];?>" value="<?= $row['c_year']?>"></td>
<td class = "courseGrade"><input type="text" size="5" name="courseGrade<?=$i;?>" id= "courseGrade<?=$alpha[$i];?>" value="<?= $row['c_grade']?>"></td>
<td class = "courseArea"><input type="text" size="5" name="courseArea<?=$i;?>" id= "courseArea<?=$alpha[$i];?>" value="<?= $row['c_area']?>"></td>
<td class = " Add"><input type = "submit" id = "Submit" name ="submit" value ="Add"/>
<td class = " Delete"><input type = "submit" id = "submit" name ="submit" value ="Delete"/>
</tr>
<?  
	$i++;
	$values = array_values($row);
}
 //echo $values[0];
	for(;$i<5;$i++){
?>
<tr id="<?=$alpha[$i];?>">
		<td>
<select id="classNumber<?=$alpha[$i];?>" name="aform1" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
 <option selected="selected"><?= $row['c_number']?></option>
 
</select> 
</td>

<td class = "courseTitle"><input type ="text" name ="courseName<?=$i;?>" size = "40" id ="courseName<?=$alpha[$i];?>" /></td>
<td class = "courseSemester"><input type="text" size="8" name="courseSemester<?=$i;?>" id= "courseSemester<?=$alpha[$i];?>" ></td>
<td class = "courseYear"><input type="text" size="8" name="couseYear<?=$i;?>" id= "courseYear<?=$alpha[$i];?>"></td>
<td class = "courseGrade"><input type="text" size="5" name="courseGrade<?=$i;?>" id= "courseGrade<?=$alpha[$i];?>" ></td>
<td class = "courseArea"><input type="text" size="5" name="courseArea<?=$i;?>" id= "courseArea<?=$alpha[$i];?>"></td>
<td class = " Add"><input type = "submit" id = "Submit" name ="submit" value ="Add"/>
<td class = " Delete"><input type = "submit" id = "submit" name ="submit" value ="Delete"/>
</tr>
<?}?>

		<!-- 
<tr>
<td>
<select id="classNumberA" width="200px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>
<!~~ 
<td>
<div id="txtHint"><b> </b></div>
</td>
 ~~>
<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameA" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterA"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearA"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeA"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaA"></td>
</tr>
		<tr>
<td>
<select id="classNumberB" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameB" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterB"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearB"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeB"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaB"></td>
</tr>
<tr>

<td>
<select id="classNumberC" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameC" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterC"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearC"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeC"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaC"></td>
</tr>

<tr>
<td>
<select id="classNumberD" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameD" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterD"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearD"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeD"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaD"></td>
</tr>
 -->
</table>

</div><!-- end courseTableWrapper div -->


<!-- 6000 level course table-->
<div class = "courseTableWrapper">

<div class = "courseTableCaption">6000 level courses </div>
<div class = "courseTableCaptionNote"> The following 6000-level courses DO NOT count towards the degree requirements: CSCI 6001</div>

<table id = "courseSelectionTable6000">
<tr>

		<th>Number</th>
		<th>Title</th>
		<th>Semester</th>
		<th>Year</th>
		<th>Grade</th>
		<th>Area</th>
		
		
<tr>
<td>
<select id="classNumberE" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>
<!-- 
<td>
<div id="txtHint"><b> </b></div>
</td>
 -->
<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameE" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterE"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearE"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeE"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaE"></td>
</tr>
<tr>
<td>
<select id="classNumberF" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameF" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterF"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearF"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeF"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaF"></td>
</tr>
				
<tr>				
<td>
<select id="classNumberG" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameG" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterG"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearG"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeG"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaG"></td>
</tr>
		<tr>				
<td>
<select id="classNumberI" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameI" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterI"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearI"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeI"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaI"></td>
</tr>
<tr>				
<td>
<select id="classNumberJ" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameJ" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterJ"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearJ"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeJ"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaJ"></td>
</tr>

<tr>				
<td>
<select id="classNumbeK" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameK" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterK"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearK"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeK"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaK"></td>
</tr>

<tr>				
<td>
<select id="classNumberL" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameL" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterL"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearL"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeL"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaL"></td>
</tr>
		<tr>				
<td>
<select id="classNumberM" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameM" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterM"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearM"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeM"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaM"></td>
</tr>
		<tr>				
<td>
<select id="classNumberN" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameN" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterN"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearN"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeN"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaN"></td>
</tr>

<tr>				
<td>
<select id="classNumberO" width="50px" name="users" onclick="fillDropDownLists(this)" onchange="fillRow(this)">
</select> 
</td>

<td class = "courseTitle"><input type ="text" size = "40" id ="courseNameO" /></td>
<td class = "courseSemester"><input type="text" size="8" id= "courseSemesterO"></td>
<td class = "courseYear"><input type="text" size="8" id= "courseYearO"></td>
<td class = "courseGrade"><input type="text" size="5" id= "courseGradeO"></td>
<td class = "courseArea"><input type="text" size="5" id= "courseAreaO"></td>
</tr>

</table>

</div><!-- end courseTableWrapper div -->


<br/>
<input type = "submit" id = "formSubmitButton" name ="formSubmitButton" value ="Save"/>


</form>
<!--courseSelectionForm.css end-->

<!-- 
<table id = "courseRulesTable" cellpadding = 0>

	
	<th> Course Requirements must fulfill  </th>

	<th>Areas of concentration</th>


	<tr>

		<td>
		<ul>
		<li><i>background</i> requirement: 5401 & 5501 if not already taken for B.S., for credit;</li><br/>
		<li><i>breadth</i> requirement: three 6000-level courses from three different concentration areas;</li>
		AND
		<li><i>depth</i> requirement: three courses (at least two 6000-level) from one concentration area different from the breadth areas chosen.</li><br/>
		Consult the <a href = "http://cs.uno.edu/academics/courses/classes/courses.php">departmental website</a> for the current list of courses offered and their corresponding areas.<br/>
		</td>

		<td>
		<ol type ="number">
			<li>Theoretical Computer Science and Programming Languages</li><br/>
			<li>Systems and Networks</li><br/>
			<li>Information Assurance</li><br/>
			<li>Software Systems</li><br/>
			<li>Database Systems and Distributed Applications</li><br/>
			<li>Computer Graphics and Visual Computing</li><br/>
			<li>Artificial Intelligence</li><br/>
		</td>


	</tr>

</table>

<font size="2"> <p><b> Note:</b> Must take Master &#39;s comprehensive examination in three courses that count towards the degree requirements &#45; subject to approval (at most one may be a 5000-level course).
 Two written and one oral exam are required. Oral exam must be taken as the last exam. Comprehensive exams can only be taken AFTER 24 credit hours have been collected that 
 count towards the degree requirements. Oral exam must be taken in the semester in which the student graduates.</p></font>

 -->


</div>


<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>


</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("db4208");
if(isset($_POST['formSubmitButton'])){
 $user_fname=$_POST['firstname'];
 $user_lname=$_POST['lastname'];
 $user_sid=$_POST['studentId'];
 $user_cnumber=$_POST['courseNumber5k1'];
 $user_ctitle1 = $_POST['couseName5k1'];
 $user_csem1 = $_POST['courseSemester5k1'];
 $user_cyear1 = $_POST['couseYear5k1'];
 $user_cgrade1 = $_POST['courseGrade5k1'];
 $user_carea1 = $_POST['courseArea5k1'];
 
 // echo " <script> alert('$user_fname')</script>";
//  echo " <script> alert($user_lname)</script>";
 // echo " <script> alert($user_sid)</script>";
//   echo " <script> alert($user_cnumber1)</script>";
//  echo " <script> alert($user_ctitle1)</script>";
// echo " <script> alert($user_csem1)</script>";
// echo " <script> alert($user_cyear1)</script>";
// echo " <script> alert($user_cgrade1)</script>";
//  echo " <script> alert($user_carea1)</script>";
 
$query="insert into data(Firstname,Lastname,Studentid,c_number,c_title,c_sem,c_year,c_grade,c_area) values ('$user_fname','$user_lname','$user_sid','$user_cnumber1','$user_ctitle1','$user_csem1','$user_cyear1','$user_cgrade1','$user_carea1') ON DUPLICATE KEY UPDATE Studentid='$user_sid'";
//$query=" insert into data(Firstname,Lastname,Studentid) values ('saida','saida','$user_sid') ";
//$myData=mysql_query($query);

if(mysqli_query($query)){
 echo " <script> alert('Data saved in database')</script>";
 }
}
?>
<?php
session_destroy();
?>